﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetfractionHub.Network;

namespace NetfractionHub.RemoteMachine
{
    public class Client : Node
    {
        private bool _isOnline;

        public Client(System.Net.Sockets.Socket clientSocket)
        {
            InitialiseFeatures();

            _lastChatMessage = null;
            this.Connection = new ClientConnection(clientSocket, this);
        }

        private void InitialiseFeatures()
        {
            // bare minimum feature
            this.Features.Add(Network.Protocol.ProtocolFeature.GetFeatureName(typeof(Network.Protocol.BASE.ProtocolFeatureBASE)), new Network.Protocol.BASE.ProtocolFeatureBASE());
        }

        public bool IsOnline
        {
            get { return _isOnline; }
            set { _isOnline = value; }
        }

        private ChatMessageProperties _lastChatMessage;

        public ChatMessageProperties LastChatMessage
        {
            get { return _lastChatMessage; }
            set { _lastChatMessage = value; }
        }

        public class ChatMessageProperties
        {
            private string _messageText;
            private DateTime _messageTime;

            public ChatMessageProperties(string messageText, DateTime messageTime)
            {
                this._messageText = messageText;
                this._messageTime = messageTime;
            }

            public string MessageText
            {
                get { return _messageText; }
                set { _messageText = value; }
            }

            public DateTime MessageTime
            {
                get { return _messageTime; }
                set { _messageTime = value; }
            }
        }
    }
}
